<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
	<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
	<script type="text/javascript" src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
   <link href="${approot}/resource/jquery/validate/jquery.validate.css" rel="stylesheet" type="text/css" />
   <link href="${approot}/resource/jquery/validate/style.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
                jQuery("#number").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "编号不能为空"
                });
                jQuery("#name").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "姓名不能为空"
                });
                jQuery("#pwd").validate({
                    expression: "if (VAL.length > 5 && VAL) return true; else return false;",
                    message: "密码不能为空,由大于6位的字母和数字组成"
                });
                jQuery("#identity").validate({
                    expression: "if ((VAL.length == 15 || VAL.length == 18) && VAL) return true; else return false;",
                    message: "身份证不能为空,且长度应为15位或18位"
                });
                jQuery('#person').validated(function(){
					//alert("通过验证");
					do_add();
				});
            });
            /* ]]> */
        </script>
        
        <script type="text/javascript">
        function do_add()
        {   
            var str=$('#person').serializeObject();
            var jsons = $.toJSON(str);
            add_person(jsons);
        }


        function add_person(jsons){
 	       $.ajax({
 		   	url:'${approot}/admin/person/add',
 		   	dataType: 'json',
 		   	contentType: 'application/json',
 			data:jsons,
 			type:'post',
 			beforeSend:function(){
 			  // $('#main').disabled='true';
 			},
 			error:function(request){
 				alert(S);
 			},
 			success:function(data){
 			   if(data.msg=="error")
 			   {
 	 			   alert('客户编号已存在,请重新输入');
 			   }
 			   if(data.msg=="succ")
 			   {
 				  alert('客户信息添加成功');
 				  //window.location.href='${approot}/admin/person/list/menu/0';
 			   }
 			}
 		   });
 	}
        </script>
   
</head>  
  <body style="background:#E8F5FE; padding:15px 18px;" class="scroll_r">
<div id="right_w"><p>当前位置：系统管理 >>新增客户信息</p></div>

<form method="post" action="${approot}/admin/person/add" id="person">
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" class="tab_l">
    <tr>
      <td><b>请按要求填写：</b></td>
      <td align="right">带<span style="color:#ff0000;">*</span>为必填</td>
    </tr>
  </table>
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" id="add_tab">
  <tr>
   <th width="20%">客户类型：</th>
   <td width="80%"><select name="personType" id="type" style="width: 18%">
 <option value="0" >零散户</option>
 <option value="1" >商业户</option> 
 <option value="2" >集体户</option> 
</select></td> 
  </tr>
  <tr>
   <th>编号：</th>
   <td><input type="text" name="personNumber" value="" id="number"><span style="color:#ff0000; margin:0;">*</span></td>
  </tr>
  <tr>
   <th width="20%">姓名：</th>
   <td width="80%"><input type="text" id="name" name="personName" value=""><span style="color:#ff0000; margin:0;">*</span></td> 
  </tr>
  <tr>
   <th width="20%">密码：</th>
   <td width="80%"><input type="text" id="pwd" name="passWord" value="123456"><span style="color:#ff0000; margin:0;">*</span></td> 
  </tr>
  
  <tr>
   <th>身份证：</th>
   <td><input type="text" name="personIdentity" value=""  id="identity"><span style="color:#ff0000; margin:0;">*</span></td>
  </tr>
  <tr>
   <th>电话：</th>
   <td><input type="text" name="personPhone" value=""  id="phone"></td>
  </tr>
  <tr>
   <th>手机：</th>
   <td><input type="text" name="personMobile" value="" id="mobile"></td>
  </tr>
 </table>
  <p id="tab_but">
  
   <input type="submit" value="提 交"></p>
</form>
</body>
</html>
